<template>
    <div>
        <edu-title title="作业管理"></edu-title>
        <div>
            <homeworkItem class="item" v-for="item in homework" :item="item" :key="item.id">
               
            </homeworkItem>
        </div>

         <el-pagination
      class="pagination"
      @current-change="getHomeWorkList"
      :page-size="pageSize"
      hide-on-single-page
      layout="prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
    <el-empty v-if="homework.length <= 0"></el-empty>
    </div>
</template>

<script>
import eduTitle from "/@/components/userCenter/title.vue";
import homeworkItem from "/@/components/userCenter/homeworkItem.vue"
import { homeworkList } from '/@/api/studyApi'

    export default {
        components: {
            eduTitle,
            homeworkItem
        },
        data(){
            return {
                total:0,
                pageSize:20,
                homework:[]
            }
        },
        mounted(){
            this.getHomeWorkList()
        },

        methods:{
          getHomeWorkList(page = 1, params = {}) {
            let offset = (page - 1) * this.pageSize;
            homeworkList({
              offset: offset,
              size: this.pageSize,
              ...params,
            })
            .then((res) => {
              const { studyProgressInfos, total } = res;
              this.homework = studyProgressInfos;
          
              this.total = total;
            })
            .catch((err) => {
              console.error(err);
            });
          },
        }
    }
</script>

<style lang="scss" scoped>
.item{
    margin-bottom: 20px;
}
</style>